var md_user=(function($){
    var app={
        init:function(){
            var _this=this;
            $("#login_form").validate(_this.loginValid);
            $("#btn_login").on("click",function(){
                if ($("#login_form").valid()){
                    md_common.postAjax("/admin/user/login",$("#login_form").serialize(),function(result){
                        if(result.info=="success"){
                            window.location.href="/admin/sys/index";
                        }
                        else{
                            if(result.code=="email"){
                                md_common.showMessage("对不起,邮箱不存在！");
                            }
                            if(result.code=="pwd"){
                                md_common.showMessage("对不起,密码不正确！")
                            }
                        }
                    });
                }
            });
        },
        loginValid:{
            rules: {
                user_email: {
                    required: true,
                    maxlength:50,
                    email:true
                },
                user_pwd: {
                    required: true,
                    maxlength:50
                }
            },
            messages: {
                user_email: {
                    required: "邮箱不能为空",
                    maxlength: "邮箱不能大于50个字符",
                    email:"请输入正确的邮箱"
                },
                user_pwd: {
                    required: "密码不能为空",
                    maxlength: "密码不能大于50个字符"
                }
            }
        }
    }
    return app;
})($);
if(typeof md_user!=undefined){
    $(function(){
        md_user.init();
    });
}
